#include "EndoscopeWidget.h"
#include "vtkObject.h"
#include "vtkObjectFactory.h"
#include "vtkSlicerApplication.h"
#include "custommodule.h"
#include "testgui.h"
#include "endoscopelogic.h"
#include <vtkRenderer.h>
#include <vtkPointData.h>
#include <memory.h>
#include <vtkKWTkUtilities.h>
vtkStandardNewMacro ( vtkEndoscopeWidget );
vtkCxxRevisionMacro(vtkEndoscopeWidget, "$Revision: 1.0 $");
vtkEndoscopeWidget::vtkEndoscopeWidget(void)
{
	RenderWidget = NULL;
	ESLogic = NULL;
}

vtkEndoscopeWidget::~vtkEndoscopeWidget(void)
{
	if (RenderWidget != NULL)
	{
		RenderWidget->SetParent(NULL);
		RenderWidget->Delete();
		RenderWidget = NULL;
	}
	SetESLogic(NULL);
}

vtkKWWidget * vtkEndoscopeWidget::Pack(vtkKWWidget *frame)
{

	vtkSlicerApplication * app = dynamic_cast<vtkSlicerApplication *>(GetApplication());
	app->Script("pack %s -in %s -side top -expand 1 -fill both", this->GetWidgetName(), frame->GetWidgetName());

	return frame;
}
void vtkEndoscopeWidget::BuildGUI(void)
{
	
}

void vtkEndoscopeWidget::CreateWidget(void)
{
	if (this->IsCreated())
	{
		vtkErrorMacro(<< this->GetClassName() << " already created");
		return;
	}

	// Call the superclass to create the whole widget

	this->Superclass::CreateWidget();

	SetBackgroundColor(0.6, 0.6, 0.6);
	RenderWidget = vtkEndoscopeRenderWidget::New();
	RenderWidget->SetParent(this);
	RenderWidget->Create();
	RenderWidget->SetApplication(GetApplication());
	RenderWidget->SetESLogic(ESLogic);
	RenderWidget->InitialPipeline();
	RenderWidget->SetWidth(640);
	RenderWidget->SetHeight(480);
	GetApplication()->Script("pack %s -expand 1", RenderWidget->GetWidgetName());

}
